package edu.msg.jthr.backend.model;

import java.util.Collections;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;

@Entity
@Table(name = "JOB")
public class Job extends BaseEntity {

	private static final long serialVersionUID = 1L;

	@NotNull
	@Column(name = "TITLE")
	private String title;

	@NotNull
	@Column(name = "MAX_CANDIDATES")
	private Integer maxCandidates;
	@Temporal(TemporalType.DATE)
	
	@Column(name = "COMMENT_DATE")
	private Date deadLine;

	@Column(name = "JOBUNICCODE")
	private String jobUnicCode;
	@OneToOne
	@JoinColumn(name = "USER_ID")
	private User proposer;

	@OneToOne(cascade = { CascadeType.ALL })
	@JoinColumn(name = "DESCRIPTION_ID")
	private JobDescription description;

	@Column(name = "OPENED")
	private Boolean opened;

	@Column(name = "APPROVED")
	private Boolean approved;

	@OneToMany(mappedBy = "job")
	private List<RecommendedCandidate> recomendedCandidates;

	@OneToMany(mappedBy = "job")
	private List<HiredCandidate> hiredCandidates;

	@OneToMany
	private List<Comment> comment;

	public Job() {
	}

	public Date getDeadLine() {
		return deadLine;
	}

	public void setDeadLine(Date deadLine) {
		this.deadLine = deadLine;
	}

	public String getJobUnicCode() {
		return jobUnicCode;
	}

	public void setJobUnicCode(String jobUnicCode) {
		this.jobUnicCode = jobUnicCode;
	}

	public Job(Long id, String uuid,String title, Integer maxCandidates, Date deadLine,
			String jobUnicCode, User proposer, JobDescription description,
			Boolean opened, Boolean approved,
			List<RecommendedCandidate> recomendedCandidates,
			List<HiredCandidate> hiredCandidates, List<Comment> comment) {
		super();
		this.title = title;
		this.maxCandidates = maxCandidates;
		this.deadLine = deadLine;
		this.jobUnicCode = jobUnicCode;
		this.proposer = proposer;
		this.description = description;
		this.opened = opened;
		this.approved = approved;
		this.recomendedCandidates = recomendedCandidates;
		this.hiredCandidates = hiredCandidates;
		this.comment = comment;
	}



	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public Integer getMaxCandidates() {
		return maxCandidates;
	}

	public void setMaxCandidates(Integer maxCandidates) {
		this.maxCandidates = maxCandidates;
	}

	public User getProposer() {
		return proposer;
	}

	public void setProposer(User proposer) {
		this.proposer = proposer;
	}

	public JobDescription getDescription() {
		return description;
	}

	public void setDescription(JobDescription description) {
		this.description = description;
	}

	public List<Comment> getComments() {
		return comment;
	}

	public void setComments(List<Comment> comment) {
		this.comment = comment;
	}

	public Boolean getOpened() {
		return opened;
	}

	public void setOpened(Boolean opened) {
		this.opened = opened;
	}

	public Boolean getApproved() {
		return approved;
	}

	public void setApproved(Boolean approved) {
		this.approved = approved;
	}

	public List<RecommendedCandidate> getRecomendedCandidates() {
		return recomendedCandidates == null ? Collections.emptyList()
				: recomendedCandidates;
	}

	public void setRecomendedCandidates(
			List<RecommendedCandidate> recomendedCandidates) {
		this.recomendedCandidates = recomendedCandidates;
	}

	public List<Comment> getComment() {
		return comment;
	}

	public void setComment(List<Comment> comment) {
		this.comment = comment;
	}

	public List<HiredCandidate> getHiredCandidates() {
		return hiredCandidates == null ? Collections.emptyList()
				: hiredCandidates;
	}

	public void setHiredCandidates(List<HiredCandidate> hiredCandidates) {
		this.hiredCandidates = hiredCandidates;
	}

}
